/*
 * WispCharacter.java
 *
 * Created on January 4, 2008, 11:23 Am
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package wisp.dataObjects;
import java.sql.*;
import java.io.*;
import java.util.*;
//import java.util.StringTokenizer;
import java.lang.Exception.*;
/**
 *
 * @author Nezie Santos
 */
public class WispCharacter {
    private dbConnection dbcon = new dbConnection();
    private String username, charactername, cClass, status, inParty, guild, online, fieldname, gender, isBlessed;
    private int level, ePoint, cMoney, cHP, mHP, cMP, mMP, cWeight, mWeight, cRank, healPt, xcoor, ycoor, sCountLeft;
    private double fPoint, dPoint; 
    public Map[] fMap = new Map[3];
    private Knapsack kn = new Knapsack();
    
    public void useItem (String iname)
    {
        kn.setIName("lala");
        kn.viewItem(charactername, iname);
        
        if (!kn.getIName().equals("lala"))
        {
            kn.editKnapsack(charactername, iname, kn.getSNum(), kn.getQuantity()-1, kn.getWeight(), kn.getItype(), kn.getIsEquiped());
            double nval;
            if (kn.getIName().equals("Bandages"))
            {
                nval = this.getCHP()+ (this.getMHP()*.15);
                if (nval < this.getMHP())
                    this.editCharInfo(this.getCharactername(), "currentHP", "", 0, (int)nval);
                else
                    this.editCharInfo(this.getCharactername(), "currentHP", "", 0, this.getMHP());
            }
            else if (kn.getIName().equals("Plasmite"))
             {
                nval = this.getCMP()+ (this.getMMP()*.20);
                if (nval < this.getMMP())
                    this.editCharInfo(this.getCharactername(), "currentMP", "", 0, (int)nval);
                else
                    this.editCharInfo(this.getCharactername(), "currentMP", "", 0, this.getMMP());
            } 
            this.viewChar(this.getCharactername());
        }   
        else 
            System.out.println("No item exist in knapsack");
    }
           
 

    /** Creates a new instance of WispCharacter */
    public double getFPoint()
    {
        return fPoint;
    }
    public double getDPoint()
    {
        return dPoint;
    }
    public int getCRank()
    {
        return cRank;
    }
    public int getCWeight()
    {
        return cWeight;
    }
    public int getMWeight()
    {
        return mWeight;
    }
    public int getCMP()
    {
        return cMP;
    }
    public int getMMP()
    {
        return mMP;
    }
    public int getMHP()
    {
        return mHP;
    }
    public int getCHP()
    {
        return cHP;
    }
    public int getCMoney()
    {
        return cMoney;
    }
    public int getEPoint()
    {
        return ePoint;
    }
    public int getLevel()
    {
        return level;
    }
    public String getGender()
    {
        return gender;
    }
    public String getInParty()
    {
        return inParty;
    }
    public String getStatus()
    {
        return status;
    }
    public String getUsername()
    {
        return username;
    }
    public String getCClass()
    {
        return cClass;
    }
    public String getCharactername()
    {
        return charactername;
    }
    public String getFieldname()
    {
        return fieldname;
    }
    
    public WispCharacter (){
        fMap[0] = new Map();
        fMap[1] = new Map();
        fMap[2] = new Map();
        
        fMap[0].setName("Allen's Hub");
        fMap[1].setName("Mommy Donya's Mansion");
        fMap[2].setName("Tigerwood's Farm");
        
        fMap[0].setId(0);
        fMap[1].setId(1);
        fMap[2].setId(2);
    }
    public WispCharacter(String uname, String cname, double ln, int xcoord, int ycoord, String charclass, String cStatus, String insideParty, String gName, String ifOnline, String fName, String cGender, int cLevel, int experiencePt, int money, int curhp, int maxhp, int curmp, int maxmp, int curweight, int maxweight, int rank, int hpt) {
        setUsername(uname);
        setCharactername(cname);
        setCClass(charclass);
        setStatus(cStatus);
        setInParty(insideParty);
        setGuild(gName);
        setOnline(ifOnline);
        setFieldname(fName);
        setGender(cGender);
        setLevel(cLevel); 
        setEPoint(experiencePt); 
        setCMoney(money);
        setCHP(curhp);
        setMHP(maxhp); 
        setCMP(curmp);
        setMMP(maxmp);
        setCWeight(curweight); 
        setMWeight(maxweight); 
        healPt = hpt;
        xcoor = xcoord;
        ycoor = ycoord;
     
        setCRank(rank);
        setFPoint(ln);
        setDPoint(100.0);
        sCountLeft = 0;
        
        fMap[0] = new Map();
        fMap[1] = new Map();
        fMap[2] = new Map();
        (fMap[0]).setName("Allen's Hub");
        (fMap[1]).setName("Mommy Donya's Mansion");
        (fMap[2]).setName("Tigerwood's Farm");
        fMap[0].setId(0);
        fMap[1].setId(1);
        fMap[2].setId(2);
    }
    
    public int generateRank ()
    {
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        int count = 1;
                
        getDbcon().connect();
        query = "SELECT * FROM WispCharacter";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {	
              count++;
             }
            rs.close(); 					
            stmt.close();					
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        getDbcon().disconnect();
        return count;
    }
    public void addCharacter (WispCharacter c){
      						
        String query; 					
        ResultSet rs;
        PreparedStatement stmt;
        c.setCRank(generateRank());
        if (!checkCnameExist(c.getCharactername()))
        {
            getDbcon().connect();
            query = "INSERT INTO WispCharacter (gender, username, characterName, class, cLevel, experiencePt, pera, currentHP, maxHP, currentMP, maxMP, currentWeight, maxWeight, status, favorPt, deedPt, characterRank, inParty, guild, online, fieldName, healPt, xcoor, ycoor, sCountLeft, isBlessed) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            try 
            {
                stmt = getDbcon().con.prepareStatement(query);
                stmt.setString(1, c.getGender());
                stmt.setString(2, c.getUsername());
                stmt.setString(3, c.getCharactername());
                stmt.setString(4, c.getCClass());
                stmt.setInt(5, c.getLevel());
                stmt.setInt(6, c.getEPoint());
                stmt.setInt(7, c.getCMoney());
                stmt.setInt(8, c.getCHP());
                stmt.setInt(9, c.getMHP());
                stmt.setInt(10, c.getCMP());
                stmt.setInt(11, c.getMMP());
                stmt.setInt(12, c.getCWeight());
                stmt.setInt(13, c.getMWeight());
                stmt.setString(14, c.getStatus());
                stmt.setDouble(15, c.getFPoint());
                stmt.setDouble(16, c.getDPoint());
                stmt.setInt(17, c.getCRank());
                stmt.setString(18, c.getInParty());
                stmt.setString (19, c.getGuild());
                stmt.setString(20, c.getOnline());
                stmt.setString(21, c.getFieldname());
                stmt.setInt (22, c.healPt);
                stmt.setInt (23, c.xcoor);
                stmt.setInt (24, c.ycoor);
                stmt.setInt (25, 0);
                stmt.setString(26, "no");
                stmt.executeUpdate();	
                stmt.close();
            } catch (Exception ex) 
            {
                System.out.println(ex.getMessage());
            }
            getDbcon().disconnect();
        }
    }
    public boolean checkCnameExist(String cname) 
    {
        //Statement stmt;
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        boolean exist = false;
                
        getDbcon().connect();
        query = "SELECT * FROM WispCharacter WHERE characterName = ?";
        
        try
        {
             	
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, cname);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {	
              exist = true;
             }
            rs.close(); 					
            stmt.close();					
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        getDbcon().disconnect();
        return exist;
    }
    
     public void viewChar (String cName){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
                
        getDbcon().connect();
        query = "SELECT sCountLeft, healPt, gender, username, characterName, class, cLevel, experiencePt, pera, currentHP, maxHP, currentMP, maxMP, currentWeight, maxWeight, status, favorPt, deedPt, characterRank, inParty, guild, online, fieldName, xcoor, ycoor, isBlessed FROM WispCharacter WHERE characterName = ?";
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, cName);
            rs = stmt.executeQuery();	
            
            while (rs.next()) 
            {	
                this.sCountLeft = rs.getInt("sCountLeft");
                this.healPt = rs.getInt("healPt");
                this.setGender(rs.getString("gender"));
                this.setUsername(rs.getString("username").trim());
                this.setCharactername(rs.getString("characterName"));
                this.setCClass(rs.getString("class").trim());
                this.setLevel(rs.getInt("cLevel"));
                this.setEPoint(rs.getInt("experiencePt"));
                this.setCMoney(rs.getInt ("pera"));
                this.setCHP(rs.getInt("currentHP"));
                this.setMHP(rs.getInt("maxHP")); 
                this.setCMP(rs.getInt("currentMP"));
                this.setMMP(rs.getInt("maxMP"));
                this.setCWeight(rs.getInt("currentWeight"));
                this.setMWeight(rs.getInt("maxWeight"));
                this.setStatus(rs.getString("status").trim());
                this.setFPoint(rs.getDouble("favorPt"));
                this.setDPoint(rs.getDouble("deedPt"));
                this.setCRank(rs.getInt("characterRank"));
                this.setInParty(rs.getString("inParty").trim());
                this.setGuild(rs.getString("guild").trim());
                this.setOnline(rs.getString("online").trim());
                this.setFieldname(rs.getString("fieldName"));
                this.setXcoor(rs.getInt("xcoor"));
                this.setYcoor(rs.getInt("ycoor"));
                this.isBlessed = rs.getString("isBlessed");
                
                //System.out.println(this.getUsername());
                //System.out.println(this.getFieldname());
             }
            
            rs.close(); 					
            stmt.close();
       
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
 
        }
     }
     
     public boolean viewCharUsingUname (String uName){
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        boolean he = false;
        getDbcon().connect();
        query = "SELECT sCountLeft, healPt, gender, username, characterName, class, cLevel, experiencePt, pera, currentHP, maxHP, currentMP, maxMP, currentWeight, maxWeight, status, favorPt, deedPt, characterRank, inParty, guild, online, fieldName, xcoor, ycoor, isBlessed FROM WispCharacter WHERE username = ?";
        //query = "SELECT * FROM WispCharacter WHERE username = ?";
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, uName);
            
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {	
                this.sCountLeft = rs.getInt("sCountLeft");
                healPt = rs.getInt("healPt");
                this.setGender(rs.getString("gender"));
                this.setUsername(rs.getString("username"));
                this.setCharactername(rs.getString("characterName"));
                this.setCClass(rs.getString("class").trim());
                this.setLevel(rs.getInt("cLevel"));
                this.setEPoint(rs.getInt("experiencePt"));
                this.setCMoney(rs.getInt ("pera"));
                this.setCHP(rs.getInt("currentHP"));
                this.setMHP(rs.getInt("maxHP")); 
                this.setCMP(rs.getInt("currentMP"));
                this.setMMP(rs.getInt("maxMP"));
                this.setCWeight(rs.getInt("currentWeight"));
                this.setMWeight(rs.getInt("maxWeight"));
                this.setStatus(rs.getString("status").trim());
                this.setFPoint(rs.getDouble("favorPt"));
                this.setDPoint(rs.getDouble("deedPt"));
                this.setCRank(rs.getInt("characterRank"));
                this.setInParty(rs.getString("inParty").trim());
                this.setGuild(rs.getString("guild").trim());
                this.setOnline(rs.getString("online").trim());
                this.setFieldname(rs.getString("fieldName").trim());
                  this.setXcoor(rs.getInt("xcoor"));
                this.setYcoor(rs.getInt("ycoor"));
                 this.isBlessed = rs.getString("isBlessed");
           //    setUserId(rs.getInt("userId"));
                System.out.println(getUsername());
                he = true;
             }
            
            rs.close(); 					
            stmt.close();
       
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
        finally {
            getDbcon().disconnect();
            return he;
        }
     }
     
      public void editCharInfo (String cName, String at, String sVal, double dVal, int iVal) {
         						
        String query; 					
        ResultSet rs;
        PreparedStatement stmt;

        getDbcon().connect();
        if (at.equals("cLevel"))
            query = "UPDATE WispCharacter SET cLevel = ? WHERE characterName = ?";
        else if (at.equals("experiencePt"))
            query = "UPDATE WispCharacter SET experiencePt = ? WHERE characterName = ?";
        else if (at.equals("pera"))
            query = "UPDATE WispCharacter SET pera = ? WHERE characterName = ?";
        else if (at.equals("currentHP"))
            query = "UPDATE WispCharacter SET currentHP = ? WHERE characterName = ?";
        else if (at.equals("maxHP"))
            query = "UPDATE WispCharacter SET maxHP = ? WHERE characterName = ?";
        else if (at.equals("currentMP"))
            query = "UPDATE WispCharacter SET currentMP = ? WHERE characterName = ?";
        else if (at.equals("maxMP"))
            query = "UPDATE WispCharacter SET maxMP = ? WHERE characterName = ?";
        else if (at.equals("currentWeight"))
            query = "UPDATE WispCharacter SET currentWeight = ? WHERE characterName = ?";
        else if (at.equals("maxWeight"))
            query = "UPDATE WispCharacter SET maxWeight = ? WHERE characterName = ?";
        else if (at.equals("status"))
            query = "UPDATE WispCharacter SET status = ? WHERE characterName = ?";
        else if (at.equals("favorPt"))
            query = "UPDATE WispCharacter SET favorPt = ? WHERE characterName = ?";
        else if (at.equals("deedPt"))
            query = "UPDATE WispCharacter SET deedPt = ? WHERE characterName = ?";
        else if (at.equals("characterRank"))
            query = "UPDATE WispCharacter SET characterRank = ? WHERE characterName = ?";
        else if (at.equals("inParty"))
            query = "UPDATE WispCharacter SET inParty = ? WHERE characterName = ?";
        else if (at.equals("guild"))
            query = "UPDATE WispCharacter SET guild= ? WHERE characterName = ?";
        else if (at.equals("online"))
            query = "UPDATE WispCharacter SET online = ? WHERE characterName = ?";
        else if (at.equals("healPt"))
            query = "UPDATE WispCharacter SET healPt = ? WHERE characterName = ?";
         else if (at.equals("xcoor"))
            query = "UPDATE WispCharacter SET xcoor = ? WHERE characterName = ?";
        else if (at.equals("ycoor"))
            query = "UPDATE WispCharacter SET ycoor = ? WHERE characterName = ?";
        else if (at.equals("sCountLeft"))
            query = "UPDATE WispCharacter SET sCountLeft = ? WHERE characterName = ?";
         else if (at.equals("isBlessed"))
            query = "UPDATE WispCharacter SET isBlessed = ? WHERE characterName = ?";
        else
            query = "UPDATE WispCharacter SET fieldName = ? WHERE characterName = ?";
        
        try 
        {
            stmt = getDbcon().con.prepareStatement(query);
            
            if (at.equals("favorPt")|| at.equals("deedPt"))
                stmt.setDouble(1, dVal);
            else if (at.equals("status") || at.equals("inParty") || at.equals("guild")|| at.equals("online") || at.equals("fieldName"))
                stmt.setString(1, sVal);
            else
                stmt.setInt(1, iVal);
            stmt.setString(2, cName);
            stmt.executeUpdate();	
            stmt.close();	
            System.out.println("==========================nag edit");
            System.out.println("========= "+cName+" "+at+" "+sVal+" "+dVal+" "+iVal);
            System.out.println("==========================nag edit");
        } catch (Exception ex) 
        {
            System.out.println(ex.getMessage());	       	
        }
        getDbcon().disconnect();
     }
      
       public void bless (String cName) {
         						
        String query; 					
        ResultSet rs;
        PreparedStatement stmt;

        getDbcon().connect();
        query = "UPDATE WispCharacter SET isBlessed = ? WHERE characterName = ?";
      
        try 
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, "yes");
            stmt.setString(2, cName);
            stmt.executeUpdate();	
            stmt.close();	
            
        } catch (Exception ex) 
        {
            System.out.println(ex.getMessage());	       	
        }
        getDbcon().disconnect();
     }
       public void unbless (String cName) {
         						
        String query; 					
        ResultSet rs;
        PreparedStatement stmt;

        getDbcon().connect();
        query = "UPDATE WispCharacter SET isBlessed = ? WHERE characterName = ?";
      
        try 
        {
            stmt = getDbcon().con.prepareStatement(query);
            stmt.setString(1, "no");
            stmt.setString(2, cName);
            stmt.executeUpdate();	
            stmt.close();	
            
        } catch (Exception ex) 
        {
            System.out.println(ex.getMessage());	       	
        }
        getDbcon().disconnect();
     }
     
   public String getCharImage(String type)
   {
       String cls = null;
       
       if (type.equals("templar") && this.getGender().equals("Female"))
           cls = "/WispApp/images/character/templar_F_large.png";
       else if (type.equals("heirophant") && this.getGender().equals("Female"))
           cls = "/WispApp/images/character/heirophant_F_large.png";
       else if (type.equals("elementalist") && this.getGender().equals("Female"))
            cls = "/WispApp/images/character/elementalist_F_large.png";
       
       else if (type.equals("templar") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/templar_M_large.png";
       else if (type.equals("elementalist") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/elementalist_M_large.png";
       else if (type.equals("heirophant") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/heirophant_M_large.png";
       
       return cls;
   }

    public void setDbcon(dbConnection dbcon) {
        this.dbcon = dbcon;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setCharactername(String charactername) {
        this.charactername = charactername;
    }

    public void setCClass(String cClass) {
        this.cClass = cClass;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setInParty(String inParty) {
        this.inParty = inParty;
    }

    public void setGuild(String guild) {
        this.guild = guild;
    }

    public void setOnline(String online) {
        this.online = online;
    }

    public void setFieldname(String fieldname) {
        this.fieldname = fieldname;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public void setEPoint(int ePoint) {
        this.ePoint = ePoint;
    }

    public void setCMoney(int cMoney) {
        this.cMoney = cMoney;
    }

    public void setCHP(int cHP) {
        this.cHP = cHP;
    }

    public void setMHP(int mHP) {
        this.mHP = mHP;
    }

    public void setCMP(int cMP) {
        this.cMP = cMP;
    }

    public void setMMP(int mMP) {
        this.mMP = mMP;
    }

    public void setCWeight(int cWeight) {
        this.cWeight = cWeight;
    }

    public void setMWeight(int mWeight) {
        this.mWeight = mWeight;
    }

    public void setCRank(int cRank) {
        this.cRank = cRank;
    }

    public void setFPoint(double fPoint) {
        this.fPoint = fPoint;
    }

    public void setDPoint(double dPoint) {
        this.dPoint = dPoint;
    }

    public dbConnection getDbcon() {
        return dbcon;
    }

    public String getGuild() {
        return guild;
    }

    public String getOnline() {
        return online;
    }
    public Vector viewCharacters (){
        //Statement stmt;
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        Vector<WispCharacter> cList;
            
        cList = new Vector<WispCharacter>();
                
        getDbcon().connect();
        query = "SELECT sCountLeft, healPt, gender, username, characterName, class, cLevel, experiencePt, pera, currentHP, maxHP, currentMP, maxMP, currentWeight, maxWeight, status, favorPt, deedPt, characterRank, inParty, guild, online, fieldName, xcoor, ycoor, isBlessed FROM WispCharacter";
        
        try
        {
            stmt = getDbcon().con.prepareStatement(query);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {	
                WispCharacter w = new WispCharacter();
                w.sCountLeft = rs.getInt("sCountLeft");
                w.healPt = rs.getInt("healPt");
                w.setGender(rs.getString("gender"));
                w.setUsername(rs.getString("username"));
                w.setCharactername(rs.getString("characterName"));
                w.setCClass(rs.getString("class").trim());
                w.setLevel(rs.getInt("cLevel"));
                w.setEPoint(rs.getInt("experiencePt"));
                w.setCMoney(rs.getInt ("pera"));
                w.setCHP(rs.getInt("currentHP"));
                w.setMHP(rs.getInt("maxHP")); 
                w.setCMP(rs.getInt("currentMP"));
                w.setMMP(rs.getInt("maxMP"));
                w.setCWeight(rs.getInt("currentWeight"));
                w.setMWeight(rs.getInt("maxWeight"));
                w.setStatus(rs.getString("status").trim());
                w.setFPoint(rs.getDouble("favorPt"));
                w.setDPoint(rs.getDouble("deedPt"));
                w.setCRank(rs.getInt("characterRank"));
                w.setInParty(rs.getString("inParty").trim());
                w.setGuild(rs.getString("guild").trim());
                w.setOnline(rs.getString("online").trim());
                w.setFieldname(rs.getString("fieldName").trim());
                w.setXcoor(rs.getInt("xcoor"));
                w.setYcoor(rs.getInt("ycoor"));
                w.isBlessed = rs.getString("isBlessed").trim();
                System.out.println("character: "+w.getCharactername());
                cList.add(w);              
             }
            rs.close(); 					
            stmt.close();
            return cList;
 				
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
       finally {
            getDbcon().disconnect();
        }
        return null;
     }
    public Vector viewAliveCharacters (){
        //Statement stmt;
        String query;
        ResultSet rs;
        PreparedStatement stmt;
        Vector<WispCharacter> cList;
            
        cList = new Vector<WispCharacter>();
        Iterator it = cList.iterator();
                
        getDbcon().connect();
        query = "SELECT sCountLeft, healPt, gender, username, characterName, class, cLevel, experiencePt, pera, currentHP, maxHP, currentMP, maxMP, currentWeight, maxWeight, status, favorPt, deedPt, characterRank, inParty, guild, online, fieldName, isBlessed FROM WispCharacter WHERE currentHP > 0";
        
        try
        {
          
             	
            stmt = getDbcon().con.prepareStatement(query);
            rs = stmt.executeQuery();	
        
            while (rs.next()) 
            {	
                WispCharacter w = new WispCharacter();
                w.sCountLeft = rs.getInt ("sCountLeft");
                w.healPt = rs.getInt("healPt");
                w.setGender(rs.getString("gender"));
                w.setUsername(rs.getString("username"));
                w.setCharactername(rs.getString("characterName"));
                w.setCClass(rs.getString("class").trim());
                w.setLevel(rs.getInt("cLevel"));
                w.setEPoint(rs.getInt("experiencePt"));
                w.setCMoney(rs.getInt ("pera"));
                w.setCHP(rs.getInt("currentHP"));
                w.setMHP(rs.getInt("maxHP")); 
                w.setCMP(rs.getInt("currentMP"));
                w.setMMP(rs.getInt("maxMP"));
                w.setCWeight(rs.getInt("currentWeight"));
                w.setMWeight(rs.getInt("maxWeight"));
                w.setStatus(rs.getString("status").trim());
                w.setFPoint(rs.getDouble("favorPt"));
                w.setDPoint(rs.getDouble("deedPt"));
                w.setCRank(rs.getInt("characterRank"));
                w.setInParty(rs.getString("inParty").trim());
                w.setGuild(rs.getString("guild").trim());
                w.setOnline(rs.getString("online").trim());
                w.setFieldname(rs.getString("fieldName").trim());
                w.isBlessed = rs.getString("isBlessed").trim();
                cList.add(w);
              
             }
            //crset.populate(rs);
            rs.close(); 					
            stmt.close();
            return cList;
 				
        } catch (Exception ex)
        {
            System.out.println(ex.getMessage());	       	
        }
       finally {
            getDbcon().disconnect();
        }
        return null;
     }
    public String getCharMiniImage(String type)
   {
       String cls = null;
       
       if (type.equals("templar") && this.getGender().equals("Female"))
           cls = "/WispApp/images/character/templar_F_small.png";
       else if (type.equals("heirophant") && this.getGender().equals("Female"))
           cls = "/WispApp/images/character/heirophant_F_small.png";
       else if (type.equals("elementalist") && this.getGender().equals("Female"))
            cls = "/WispApp/images/character/elementalist_F_small.png";
       
       else if (type.equals("templar") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/templar_M_small.png";
       else if (type.equals("elementalist") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/elementalist_M_small.png";
       else if (type.equals("heirophant") && this.getGender().equals("Male"))
           cls = "/WispApp/images/character/heirophant_M_small.png";
       
       return cls;
   }

    public int getHealPt() {
        return healPt;
    }

    public void setHealPt(int healPt) {
        this.healPt = healPt;
    }

    public int getXcoor() {
        return xcoor;
    }

    public void setXcoor(int xcoor) {
        this.xcoor = xcoor;
    }

    public int getYcoor() {
        return ycoor;
    }

    public void setYcoor(int ycoor) {
        this.ycoor = ycoor;
    }

    public int getSCountLeft() {
        return sCountLeft;
    }

    public void setSCountLeft(int sCountLeft) {
        this.sCountLeft = sCountLeft;
    }

    public String getIsBlessed() {
        return isBlessed;
    }

    public void setIsBlessed(String isBlessed) {
        this.isBlessed = isBlessed;
    }
}
